// ============================== 导入依赖 ============================== //

import state from '@admin/components/detail/DetailRepair/store/state'
import workstate from '@admin/views/Workbench/WorkbenchPersonal/LeftWork/WorkRepair/store/state'
import API from './API'

const STATUS = workstate.INIT_INFO.STATUS.reduce((array, [code, name, , color]) => {
  const statusList = code.split(',')
  const dictList = statusList.map((status) => [status, name, '', color])
  array.push(...dictList)
  return array
}, [])

const WORD = '工单'

// ============================== 导出状态集 ============================== //

export default {
  // —————————————————————————————— 常量状态 —————————————————————————————— //

  /**
   * 接口
   */
  API: {
    MENU: ['__详情__', WORD], // 菜单
    ...API,
  },

  /**
   * 映射
   */
  MAP: {
    // 词语
    WORD,

    // 必须的字段，有值才会显示弹窗
    REQUIRED_KEY: state.MAP.REQUIRED_KEY,

    // 弹窗属性
    MODEL_PROPS: state.MAP.MODEL_PROPS,

    task_receive: [
      { operate: '接单', method: 'receive' },
    ],
    task_process: [
      { operate: '处理', method: 'process' },
      { operate: '回退', method: 'back' },
      { operate: '转派', method: 'forward' },
      { operate: '挂起', method: 'suspend' },
    ],
    task_suspend_review: [
      { operate: '解挂', method: 'resume' },
    ],
    task_suspend: [
      { operate: '解挂', method: 'resume' },
    ],
    task_complete: [],
    task_review: [],
  },

  /**
   * 字典
   */
  DICT: {
    /**
     * 状态
     */
    STATUS,
  },

  /**
   * 首要开关
   *
   * 1. 初始化完成时调用
   * 2. 提交后刷新时调用
   */
  MAIN_START: 'startOne', // 'startInfo' 或 'startList' 或 'startOne' 或 ''

  /**
   * 初始单项
   *
   * 1. 初始存在，才能响应
   * 2. setOne() 合并时使用
   * 3. openAdd() 新增时使用
   */
  INIT_ONE: state.INIT_ONE,
}
